home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMIBEST4.ADF
/
AmigaBasicStuff
/
BasicSorts
/
InsertionSort.DOC
< prev
next >
Wrap
Text File
|
1987-07-22
|
1KB
|
36 lines
INSERTION SORT DOCUMENTATION
This is a fine-tuned version of Insertionsort as presented in Programming
Pearls by Jon Bentley from AT&T Bell Laboratories. The file is ready to
merge into your AmigaBasic program via the MERGE command (read the
AmigaBasic manual for details concerning MERGE). From your program just
call the Insertionsort like this:
call InsertionSort ( m$(),n% )
where m$() is the array to be sorted and n% is the upper limit of the array
m$(1..n%). See what I mean? The first element in the array must be at the
index 1 and NOT 0 or else the 0 element will not be sorted.
I have tested the code on m$(1..n%) with each field of m$() being 25
characters in length with the following results:
N Time to Sort in Seconds
------------------------------------------------
10 1
20 2
50 5
100 17
This algorithm is an O(n^2) algorithm.
Send further questions concerning this code to :
Gregory A. Kendall
ATN/ Brendallson Software
522 Neese Road
Woodstock, GA 30188
Auf Wiedersehen!